var $ = getApp(), methods = require("../methods.js");
var interval = null;
Page(Object.assign({}, methods, {
	data: {
		prodata: '',
		isload: 0,
		djs:'',
	},
	_onLoad: function (option) {
		var that = this;
		$.get('peisong/orderdetail', { id: that.options.id }, function (res) {
			that.setData({
				iscommentdp:res.iscommentdp,
				detail: res.detail,
				prolist: res.prolist,
				shopset: res.shopset,
				storeinfo: res.storeinfo,
				lefttime:res.lefttime,
				codtxt:res.codtxt,
				isload: 1,
				psorder:res.psorder
			});
			$.loading(false);
			if(res.lefttime > 0){
				interval = setInterval(function(){
					that.setData({lefttime: that.data.lefttime+1})
					that.getdjs();
				},1000)
			}
		});

	},
	setst: function (e) {
		var that = this;
		var id = e.currentTarget.dataset.id
		var st = e.currentTarget.dataset.st
		if(st==1){
			var tips = '确定要改为正在配送中吗?';
		}else{
			var tips = '确定已完成配送吗?';
		}
		$.confirm(tips, function () {
			$.post('peisong/setst', { id: id,st:st }, function (data) {
				$.success(data.msg);
				setTimeout(function () {
					that.onLoad();
				}, 1000)
			}, '提交中');
		})
	},
	onUnload:function(){
		clearInterval(interval);
	}
}))